<template>
  <el-form-item :class="getClz()" :label="opt.text" :prop="opt.name" v-if="!opt.hide"  v-bind="opt.itemProps">
    <el-switch
      style="display: block"
      v-model="data[opt.name]"
      :active-text="''"
      :inactive-text="opt.text2"
      :active-value="opt.active[1]"
      :inactive-value="opt.active[0]"
      v-bind="opt.props"
      @change="onChange(data,column)"
    >
    </el-switch>
  </el-form-item>
</template>

<script>
  import extend from '../extend';

  export default {
    name: "FormSwitch",
    mixins:[extend],
    data(){
      return {
        opt:{
          name:'',
          text:'',
          text2:'',
          className:'',
          itemProps:{
            //
          },
          active:[false,true],
          props:{
            type:'text',
            disabled:false
          },
          hide:false,
        }
      }
    },
    created(){
      this.initOptions();
      this.onChange = this.column.onChange||Log;
    },
    methods:{
      setValue(val){
        this.data[this.opt.name] = val;
      }
    }
  }
</script>
